package main

import (
	"fmt"
	"math/rand"
	//"runtime"
	"time"
	//"github.com/toolkits/time"
)

func test(ch chan int, i int) {
	ch <- rand.Int()
	fmt.Println(i, "go...", len(ch))
}

func main() {

	//chs := make([]chan int, 10)
	chs := make(chan int, 10)
	for i := 0; i < 1000; i++ {
		//runtime.Gosched()
		go test(chs, i)
	}
	//for _, ch := range chs {
	for i := 0; i < 1000; i++ {
		time.Sleep(1 * time.Second)
		value := <-chs
		fmt.Println(len(chs), value)

	}

	//}

	//var i int
	//fmt.Scan(&i)
	//fmt.Println("done")
}
